<template>
  <zm-dialog title="申请延期" :visible.sync="value" append-to-body :before-close="dialogClose" :close-on-click-modal="false" size="small">
    <p class="fc-orange mb20">客户即将移入公海时，可申请延后移交（审批期间客户将不会被自动移入公海）</p>
    <zm-form :model="form" ref="form" :rules="rules">
      <zm-form-item label="延期天数" prop="postponeDays">
        <zm-data-select v-model="form.postponeDays" :list="dayList" placeholder="选择延期天数" class="w200"></zm-data-select>
      </zm-form-item>
      <zm-form-item label="延期理由" prop="postponeRemark">
        <zm-input type="textarea" class="w500" :maxlength="300" show-word-limit v-model="form.postponeRemark" placeholder="请输入备注信息" />
      </zm-form-item>
    </zm-form>
    <div slot="footer" class="tr">
      <el-button @click="dialogClose">取 消</el-button>
      <el-button type="primary" @click="submit">确 定</el-button>
    </div>
  </zm-dialog>
</template>

<script>
import dialogMixin from '@/mixins/dialogMixin'
import { approvePostpone } from '@/api/src/customer'
export default {
  components: {},
  mixins: [dialogMixin],
  props: {
    id: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
      form: {
        businessId: this.id,
        postponeDays: '',
        postponeRemark: ''
      },
      rules: {
        postponeDays: { required: true, message: '请选择', trigger: true },
        postponeRemark: { required: true, message: '请输入', trigger: true }
      }
    }
  },
  computed: {
    dayList () {
      return [
        {
          value: '10',
          name: '10天'
        }, {
          value: '20',
          name: '20天'
        }, {
          value: '30',
          name: '30天'
        }
      ]
    }

  },
  created () { },
  methods: {
    async submit () {
      let _valid = false
      this.$refs.form.validate(valid => {
        _valid = valid
      })
      if (!_valid) return
      await approvePostpone(this.form)
      this.$message.success('操作成功')
      this.$emit('after')
      this.dialogClose()
    }
  }
}
</script>
<style lang="scss">
</style>
